<?php
/**
 * Enter description here...
 *	
 * STATUS_DISABLE 0 
 * STATUS_ABLE 1 
 */
class Template extends CActiveRecord {
	public static function model($className = __CLASS__) {
		return parent::model ( $className );
	}
	
	public function tableName() {
		return '{{template}}';
	}
	
	public function rules() {
		return array (
			
			array (
				
				'id,template,type', 
				'required', 
				'message' => '不能为空' 
			) 
		);
	}
	
	public function relations() {
		return array ();
	}
	
	public function attributeLabels() {
		return array (
			
			'id' => 'id', 
			'template' => 'template', 
			'type' => 'type' 
		);
	}
	
	public function getTplByType($type = "sys") {
		if ($type == "all") {
			$rows = $this->findAll ();
			return CommonFunc::YiiobjectToArray ( $rows, "all" );
		}
		$rows = $this->find ( array (
			
			"condition" => "type='$type'" 
		) );
		return CommonFunc::YiiobjectToArray ( $rows, "one" );
	}
}
?>
